Skip to content

Conversation

@ahouseholder
Copy link
Contributor

@ahouseholder ahouseholder commented Sep 18, 2025

Thanks to @bernhardreiter for the suggestion.

Copilot Summary

This pull request refactors how namespace regular expressions are handled throughout the codebase. The main change is the removal of the compiled regex object NS_PATTERN in favor of using the raw pattern string NS_PATTERN_STR directly, with explicit calls to re.match or re.search where needed. This simplifies imports and clarifies the use of regex patterns in both the main code and tests.

Refactoring of namespace pattern usage:

  • Replaced all imports and usages of the compiled regex object NS_PATTERN with the raw pattern string NS_PATTERN_STR across modules and tests, ensuring that regex operations use re.match or re.search explicitly. [1] [2] [3] [4] [5] [6]
  • Updated all validation and test logic to use re.match(NS_PATTERN_STR, ...) and re.search(NS_PATTERN_STR, ...) instead of calling methods on the compiled object. [1] [2] [3] [4] [5]

Code cleanup:

  • Removed unnecessary imports of re in src/ssvc/utils/patterns.py and deleted the now-unused compiled NS_PATTERN object. [1] [2]

These changes make the use of namespace regex patterns more explicit and consistent, reducing confusion and potential errors from mixing pattern strings and compiled regex objects.

@ahouseholder ahouseholder added this to the 2025-09 milestone Sep 18, 2025
@ahouseholder ahouseholder self-assigned this Sep 18, 2025
@ahouseholder ahouseholder added the tech/backend Back-end tools, code, infrastructure label Sep 18, 2025
Copy link
Contributor

@sei-vsarvepalli sei-vsarvepalli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@ahouseholder ahouseholder merged commit 10896f3 into main Sep 25, 2025
4 checks passed
@ahouseholder ahouseholder deleted the use-NS_PATTERN_STR branch September 25, 2025 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tech/backend Back-end tools, code, infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

What about using NS_PATTERN_STR instead of NS_PATTERN.pattern and remove NS_PATTERN entirely? It would be an additional simplification.

3 participants